﻿@model HanGu.Entity.Message
@{
    Layout = null;
    TempData["Remark"] = Model.Remark;
    var Attachments = ViewData["Attachments"] as List<HanGu.Entity.FileManage> ?? new List<HanGu.Entity.FileManage>();
    var action = Request["action"];
    var read = (action != null && action == "read") || string.IsNullOrEmpty(Model.Receiver);
    var isNoSend = string.IsNullOrEmpty(Model.Receiver);
}
<div class="pageContent">
    <style>
        #FileInputUploader
        {
            padding-left: 130px;
        }
    </style>
    <script>
        function onallcomplete(event, id, fileObj, response, data) {


        }
        function uploadifyComplete(event, queueId, fileObj, response, data) {
            var html = "<div class='uploadedFile'>" + fileObj.name + "</div>";
            $("#uploadedFile").html($("#uploadedFile").html() + html);
            DWZ.ajaxDone(DWZ.jsonEval(response));

        }


    </script>
    <form method="post" action="/Message/Default/Email?OpID=@ViewData["OperateID"]" enctype="MULTIPART/FORM-DATA"
    class="pageForm required-validate" onsubmit="return validateCallback(this, dialogAjaxDone)">
    @Html.ValidationSummary(true)
    <div class="pageFormContent" layouth="56">
        @Html.HiddenFor(model => model.ID)
        @Html.HiddenFor(model => model.Type)
        @Html.Hidden("Email.MemberID", ViewData["membersID"])
        @Html.HiddenFor(model => model.CreateTime)
        @Html.HiddenFor(model => model.Creator)
        @Html.HiddenFor(model => model.GUID)
        @Html.HiddenFor(model => model.Receiver)
        @Html.Hidden("action", "m")
        @if (isNoSend)
        {
            <p style="width: 100%; height: auto">
                <span style="color: Red; font-weight:bold">注意：客户设置不接收邮件或未填写邮件地址</span>
            </p>
        }
        <p style="width: 100%; height: auto">
            <label>
                接收客户：</label>
            
                @HttpUtility.UrlDecode(ViewData["membersName"] as string, System.Text.Encoding.GetEncoding("UTF-8"))
           
        </p>
        <p style="width: 100%; height: auto">
            <label>
                接收邮箱：</label>            
                @Request["emails"]           
        </p>
        <p style="width: 100%">
            <label>
                标题：</label>
            @Html.TextBoxFor(model => model.Title, new { @class = "required", style = "width:400px" })
            @Html.ValidationMessageFor(model => model.Receiver)
        </p>
        @if (Request["action"] != "view")
        {
            <label>
                附件：
            </label>
        
            <div id="fileQueue" class="fileQueue">
            </div>
            <input id="FileInput" type="file" name="image" uploader="/Content/uploadify/scripts/uploadify.swf"
            cancelimg="Content/uploadify/cancel.png" script="/FileManage/SaveFiles" scriptdata="{ClassType:'Temp', guid:'@Model.GUID',GroupName:''}"
            filequeue="fileQueue" onallcomplete="uploadifyComplete" fileExt="*.*" fileDesc="*.*"/>
        }
        <div class="divider">
        </div>
        <p>
            <label>
                已上传附件：</label>
            <div id="uploadedFile" style="margin-left: 130px">
                @if (Attachments != null && Attachments.Count > 0)
                {
                    foreach (var item in Attachments)
                    { 
                    <div>
                        <a href="@item.FilePath" target="_blank">@item.FilePath</a></div>
                    }
                }
            </div>
        </p>
        <p style="width: 100%; height: 200px">
            <label>
                内容：</label>
            @Html.Partial("Editor", new HanGu.Entity.EditorDTO() { CrontrollID = "Remark", Value = Model.Remark })
            @Html.ValidationMessageFor(model => model.Remark)
        </p>
    </div>
    @if (Request["action"] != "view")
    {
        <div class="formBar">
            <ul>
                @if (!read)
                {
                    <li>
                        <div class="buttonActive">
                            <div class="buttonContent">
                                <button type="submit">
                                    提交</button></div>
                        </div>
                    </li>
                }
                <li>
                    <div class="button">
                        <div class="buttonContent">
                            <button type="button" class="close">
                                取消</button></div>
                    </div>
                </li>
            </ul>
        </div>
    }
    </form>
</div>
